home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_06 / democ.c < prev    next >
Text File  |  1995-01-01  |  2KB  |  111 lines

  1. /*
  2.     16/06/87
  3.  
  4.     Sound-driver demonstration program.
  5. */
  6.  
  7.  
  8. #define    fSDInit            0
  9. #define    fSDRelTimeStart        2
  10. #define    fSDSetState        3
  11. #define    fSDGetState        4
  12. #define    fSDFlush        5
  13. #define    fSDSetMode        6
  14. #define    fSDGetMode        7
  15. #define    fSDSetRelVolume        8
  16. #define    fSDSetTempo        9
  17. #define    fSDSetTranspose        10
  18. #define    fSDGetTranspose        11
  19. #define    fSDSetActVoice        12
  20. #define    fSDGetActVoice        13
  21. #define    fSDPlayNoteDel        14
  22. #define    fSDPlayNote        15
  23. #define    fSDSetTimbre        16
  24. #define    fSDSetPitch        17
  25. #define    fSDSetTickBeat        18
  26. #define    fSDNoteOn        19
  27. #define    fSDNoteOff        20
  28. #define    fSDTimbre        21
  29.  
  30.  
  31.  
  32. #define END        100            /* indicate the end of 'melodie' array */
  33.  
  34. int marimba3[] = {
  35.  0x0001, 0x0005, 0x0005, 0x000d, 0x0001, 0x0000, 0x000a, 0x0005, 0x000e,
  36.  0x0001, 0x0000, 0x0000, 0x0001, 0x0002, 0x0001, 0x0000, 0x000f, 0x0001,
  37.  0x0000, 0x0009, 0x0003, 0x0000, 0x0001, 0x0000, 0x0000, 0x0001
  38. };
  39.  
  40.  
  41.  
  42. char melodie[] = {
  43. 0, 1, 2,
  44. 2, 1, 2,
  45. 4, 3, 4,
  46. 7, 1, 4,
  47. 7, 1, 1,
  48. 4, 3, 4,
  49. 0, 1, 4,
  50. 4, 3, 2,
  51. 2, 1, 2,
  52. 0, 2, 1,
  53.  
  54. 0,1,2,
  55. 4,1,2,
  56. 7,1,2,
  57. 12,3,2,
  58. 2,3,4,
  59. 5,1,4,
  60. 9,1,2,
  61. 12,3,2,
  62. 11,3,4,
  63. 9,1,4,
  64. 7,1,2,
  65. 5,1,1,
  66. 2,1,2,
  67. 4,1,1,
  68. 9,1,2,
  69. 7,3,2,
  70. 100, 100, 100
  71. };
  72.  
  73.  
  74. extern    char SoundCall();            /* interface to sound-driver */
  75.  
  76.  
  77. main()
  78. {
  79.     int i;
  80.  
  81.     if( !GetSoundDrvVersion()) {        /* verify that sound-driver is installed */
  82.         printf( "\n Sound-driver not installed!");
  83.         exit( 1);
  84.         }
  85.     SoundCall( fSDInit);            /* reset sound-driver */
  86.     SoundCall( fSDSetState, 0);        /* make shure that sound-driver is disabled */
  87.     SoundCall( fSDSetMode, 0);        /* set to melodic mode */
  88.     SoundCall( fSDSetTickBeat, 4);        /* 4 ticks by beats */
  89.     SoundCall( fSDRelTimeStart, 0, 1);    /* start of music piece */
  90.     SoundCall( fSDSetTempo, 100, 0, 1);    /* set tempo to 100 */
  91.     SoundCall( fSDSetActVoice, 0);            /* use voice 0 */
  92.     SoundCall( fSDSetTimbre, &marimba3[ 0], 0, 1);    /* set timbre voice */
  93. /*
  94.     Play all notes of 'melodie' array....
  95. */
  96.     i = 0;
  97.     while( 1) {
  98.         if( END == melodie[ i])
  99.             break;
  100.         SoundCall( fSDPlayNote, (unsigned)melodie[ i], (unsigned)melodie[ i+1],
  101.             (unsigned)melodie[ i+2]);
  102.         i += 3;
  103.         }
  104.     SoundCall( fSDSetState, 1);            /* enable the sound-driver to play */
  105.     while( SoundCall( fSDGetState))            /* wait until the last note */
  106.         ;
  107.     printf( "\nDone!");
  108.     exit( 0);
  109. }
  110.  
  111.